package _4stream;

import _0entity.Student;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Description:
 * @Author wangzhen
 * @Date 2020/8/24
 **/
public class StreamDemo {


    public static void main(String[] args){
        List<Student> studentList=new ArrayList<Student>();
        studentList.add(new Student(12,"小张"));
        studentList.add(new Student(10,"小李"));
        studentList.add(new Student(11,"小花"));
        studentList.add(new Student(12,"小明"));
        studentList.add(new Student(11,"小明"));
//        studentList.stream().sorted((v1,v2) -> v1.getAge() - v2.getAge()).forEach(System.out::println);
//        List<String> list = studentList.stream()
//                                    .anyMatch((val) -> val.getName().equals("小红"))
//                                    .collect(Collectors.toList());
        System.out.println(studentList.stream().anyMatch((val) -> val.getName().equals("小红")));//false
        System.out.println(studentList.stream().anyMatch((val) -> val.getName().equals("小花")));//true


        int arr[]={1,2,3,1};
        Arrays.stream(arr).limit(2).forEach(System.out::println);//2,3

    }
}
